package view;

import javax.swing.BorderFactory;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

/**
 * @author Andrea
 * 
 */
public class GeneralTextArea {
	JTextArea makeTextField(String title, int rows, int vertScrollbar,
			boolean canEdit) {
		JTextArea current = new JTextArea();
		current.setRows(rows);
		current.setBorder(BorderFactory.createTitledBorder(title));
		current.setLineWrap(true);
		current.setWrapStyleWord(true);

		JScrollPane scroller = new JScrollPane(current);
		if (vertScrollbar == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
			scroller.setVerticalScrollBarPolicy
				(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		else if (vertScrollbar == ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED)
			scroller.setVerticalScrollBarPolicy
				(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
		else
			scroller.setVerticalScrollBarPolicy
				(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

		if (canEdit == true)
			current.setEditable(true);
		else
			current.setEditable(false);

		return current;
	}
}
